﻿using System.Diagnostics;
using System.Windows;
using DemoWindowsPhoneMvp.Logic.Messages;
using WindowsPhoneMvp;
using System;

namespace DemoWindowsPhoneMvp.Logic.Views.Shared
{
    public class WidgetPresenter : Presenter<IWidgetView, WidgetViewModel>, IDisposable
    {
        public WidgetPresenter(IWidgetView view) : base(view)
        {
            View.Load += ViewLoad;
        }

        void ViewLoad(object sender, EventArgs e)
        {
            Messages.Subscribe<HelloMessage>(x => Model.Message = x.Monkey, 
                () => MessageBox.Show("HelloMessage never received :("));
        }

        public override void OnNavigationTo(WindowsPhoneMvp.Navigation.NavigationData navigationData)
        {
            base.OnNavigationTo(navigationData);
        }

        public override void OnNavigatedFrom(bool isExiting)
        {
            base.OnNavigatedFrom(isExiting);
        }

        public override void OnActivated()
        {
            base.OnActivated();
        }

        public override void OnDeactivated()
        {
            base.OnDeactivated();
        }

        void IDisposable.Dispose()
        {
            Debug.WriteLine("Calling Dispose on Control view");
        }
    }
}
